﻿using System;
using UnityEngine;

namespace AI.Graph {


    /// <summary>
    /// Add this Attribute to a ConnectionPort.
    /// </summary>
    [AttributeUsage (AttributeTargets.Field)]
    public class Port : Attribute {

        private readonly Direction direction;
        private readonly Capacity capacity;
        private readonly string name;
        private readonly Type[] allowedConnections;


        public Port (Direction direction, Capacity capacity, string name, params Type[] allowedConnections) {
            this.direction = direction;
            this.capacity = capacity;
            this.name = name;
            this.allowedConnections = allowedConnections;
        }


        public ConnectionPort CreateNew (Node node) {
            ConnectionPort port = ScriptableObject.CreateInstance<ConnectionPort> ();
            port.Initialize (direction, capacity, node, name, allowedConnections);
            node.AddConnectionPort (port);
            return port;
        }

    }


}